<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var str = '<div><div>1111ad</div><div>2222</div></div>';
        // \正则中的转义字符
        // var reg = /<div>(.*)<\/div>/;

        // var result = str.match(reg);
        // console.log(result);

        // 禁止贪婪模式
        var reg2 = /<div>(.*?)<\/div>/;
        var result2 = str.match(reg2);
        console.log(result2);


        // () 原子：完整匹配后，继续做子匹配，获得子匹配中的内容
        var str123 = "marginTop:50px;fontSize:80px;";
        var reg = /marginTop:(\d+)px;fontSize:(\d+)px;/;

        var result = str123.match(reg);
        console.log('result: ', result);
    </script>
</body>

</html>